package com.heima.feigns.fallback;

import com.heima.feigns.ArticleFeign;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ArticleFeignFallback implements FallbackFactory<ArticleFeign> {
    @Override
    public ArticleFeign create(Throwable throwable) {
        return new ArticleFeign() {
            @Override
            public ResponseResult<ApAuthor> findByUserId(Integer userId) {
                log.error("远程调用Article服务 findByUserId 方法出错  参数为{}  异常为{}",userId,throwable.getMessage());
                return null;
            }

            @Override
            public ResponseResult<ApAuthor> saveUser(ApAuthor apAuthor) {
                log.error("远程调用Article服务 saveUser 方法出错  参数为{}  异常为{}",apAuthor,throwable.getMessage());
                return null;
            }

            @Override
            public ResponseResult findArticleById(Long id) {
                log.error("远程调用Article服务 findArticleById 方法出错  参数为{}  异常为{}",id,throwable.getMessage());
                return null;
            }
        };
    }
}
